'use client';

import { usePathname, useRouter } from 'next/navigation';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs';

export default function HomePageList({
  recommendList,
  nearbyList,
}: {
  recommendList: React.ReactNode;
  nearbyList: React.ReactNode;
}) {
  const { replace } = useRouter();
  const pathname = usePathname();
  return (
    <Tabs
      defaultValue="recommend"
      className="w-full"
      onValueChange={() => replace(pathname)}
    >
      <TabsList className="grid w-full grid-cols-2">
        <TabsTrigger value="recommend">推荐</TabsTrigger>
        <TabsTrigger value="nearby">附近</TabsTrigger>
      </TabsList>
      <TabsContent value="recommend" className="py-5">
        {recommendList}
      </TabsContent>
      <TabsContent value="nearby" className="py-5">
        {nearbyList}
      </TabsContent>
    </Tabs>
  );
}
